#include <linux/module.h>
#include <linux/init.h>
#include <linux/err.h>
#include <linux/platform_device.h>
#include <linux/leds.h>

void set_brightness(struct led_classdev *led_cdev, enum led_brightness brightness)
{
	printk("Func: %s, name: %s, brightness: %d\n", __FUNCTION__, led_cdev->name, brightness);
}

int set_brightness_sync(struct led_classdev *led_cdev, enum led_brightness brightness)
{
	printk("Func: %s, name: %s, brightness: %d\n", __FUNCTION__, led_cdev->name, brightness);
	return 0;
}

enum led_brightness get_brightness(struct led_classdev *led_cdev)
{
	printk("Func: %s, name: %s\n", __FUNCTION__, led_cdev->name);
	return 6;
}

struct led_classdev led_dev = {
	.name = "test-led",
	.brightness = 0,
	.max_brightness = 255,
	.brightness_set_sync = set_brightness_sync,
//	.brightness_set = set_brightness,
	.brightness_get = get_brightness,
};

static int __init led_init(void)
{
	int ret = 0;

	ret = led_classdev_register(NULL, &led_dev);
	if (ret) {
		printk("led register err: %d\n", ret);
		return ret;
	}

	return ret;
}

static void __exit led_exit(void)
{
	led_classdev_unregister(&led_dev);
}

module_init(led_init);
module_exit(led_exit);
MODULE_LICENSE("GPL");
MODULE_AUTHOR("YYW");
